<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>作用域</title>
  </head>
  <body>
    <script>
      var age = 18;
      function ageNum() {
        var age = 39;
        console.log(age); // 访问函数内部的作用域
      }
      ageNum();
      console.log(age); // 访问全局作用域

      var test1 = "vue";
      function fun1() {
        function fun2() {
          function fun3() {
            var test3 = "angular";
            console.log(test3);
          }
          fun3();
          var test2 = "react";
          console.log(test2);
        }
        fun2();
        console.log(test1);
      }
      fun1();

      console.log(test1); // 全局作用域
    </script>
  </body>
</html>
